package com.example.demo1104.demo2;

import java.util.function.Function;
import java.util.function.Supplier;

public class Test05 {
    public static void main(String[] args) {


        Function<String,Cat> function=(t)->new Cat(t);
        Cat c = function.apply("野猪佩奇");
        System.out.println(c);

        Function<String, Cat> function01=Cat::new;
        Cat a = function01.apply("野猪乔治");
        System.out.println(a);

        Supplier<Cat> supplier=()->new Cat();
        System.out.println(supplier.get());

        Supplier<Cat> sup=Cat::new;
        System.out.println(sup.get());

    }
}
class Cat{
    private String name;

    public Cat() {
    }

    public Cat(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
